﻿using Boo.Lang;

namespace Mite
{
	/// <summary>
	/// An index
	/// </summary>
	public class Index
	{
		/// <summary>
		/// Creates an index applying to <paramref name="table"/>.
		/// </summary>
		/// <param name="table">Table to which this index applies.</param>
		public Index(string name, Table table, bool isUnique, Hash options, params Column[] columns)
		{
			Guard.ArgumentNotNull("table", table);
			Guard.StringArgumentNotNullOrEmpty("name", name);

			Name = name;
			Table = table;
			Columns = columns;
			Options = options;
			IsUnique = isUnique;
		}

		public Index(string name, Table table, bool isUnique, params Column[] columns)
			: this(name, table, isUnique, new Hash(), columns)
		{
		}

		public Index(string name, Table table, params Column[] columns) : this(name, table, false, columns)
		{
		}

		/// <summary>
		/// Name of this index.
		/// </summary>
		public string Name { get; private set; }

		/// <summary>
		/// Table that contains the columns being indexed.
		/// </summary>
		public Table Table { get; private set; }

		/// <summary>
		/// The columns to which this index applies.
		/// </summary>
		public Column[] Columns { get; private set; }

		/// <summary>
		/// <c>True</c> if the index allows duplicate entries.  <c>False</c> if it does not.
		/// </summary>
		public bool IsUnique { get; private set; }

		/// <summary>
		/// Options that individal providers may or may not respect.
		/// </summary>
		public Hash Options { get; private set; }
	}
}